#include"include.h"
int main()
{
   httpreq_t request = HTTPREQ_DEFAULT;
   request.method = "GET";
   request.reqURI = "/";
   request.protoVersion = "HTTP/1.1";

   dict_t *reqHeaders = newDict( (int (*)(const void *, const void *))strcmp);
   dictPut(reqHeaders, "Host", "www.google.com");
   request.headers = reqHeaders;

   dict_t *parms = newDict( (int (*)(const void *, const void *))strcmp);
   dictPut(parms, "Test_Parm", "HelloParms");
   dictPut(parms, "id", "7");
   request.parameters = parms;

   mystr *data = makeHTTPRequestData(request);
   mystr dat = *data;
   free(data);


   printf("Constructing a GET request to www.google.com with:\n");
   printf("  Params:\n    Test_Parm: HelloParms\n");
   printf("    id: 7\n");
   printf("  Headers:\n    Host: www.google.com\n");

   printf("\n%s", dat.s);

   // Need to actually make request and receive response
   httpreq_t req2 = HTTPREQ_DEFAULT;
   req2.method = "GET";
   req2.reqURI = "/";
   req2.headers = reqHeaders;
   httpresp_t resp = make_request(req2);

   printf("Response from google:\n");
   printf("Status Line:\n");
   printf("\t%s %d\n", resp.protoVersion, resp.statusCode);
   printf("Headers:\n");
   list_t *hdrs = dictTraversal(resp.headers);
   resetList(hdrs);
   dict_key_val_t *keyval;
   while(!endList(hdrs))
   {
      keyval = getObject(hdrs);
      printf("\t%s: %s\n", (char *) keyval->key, (char *) keyval->val);
   }

   return 0;
}
